class RSA:
	def kg(self):
		e = 2^16 + 1
		while 1:
			p = lib().prime_gen(1900,  9)
			if((p - 1) % e != 0): break
		while 1:
			q = lib().prime_gen(1172, 15)
			if((q - 1) % e != 0): break
		n = p * q
		phi_n = (p - 1) * (q - 1)
		d = inverse_mod(e, phi_n)
		return ((n,e), (n,d))
		
	def enc(self, (n, e), M):
		if(M >= n):  raise NameError("RSA: enc(): 'M' too large")
		C = power_mod(M, e, n)
		return C
	
	def dec(self, (n,d), C):
		if(C >= n):  raise NameError("RSA: dec(): 'C' too large")
		M = power_mod(C, d, n)
		return M